refactored two 'if' blocks into an 'if else' statement