Refactoring

Changed a nested if statement to be an easier to read guard statement instead.