Refactor to remove nested IF
PHPCS standard now checks for superfluous whitespace