Refactored if statement

Refactored an if statement as my compiler was complaining there was no return in the function