Refactor function to return same type

Hey there.

I’ve moved your post to a category where you can report false-positives. Feel free to update your post with the information asked for: