Replaced conditional operator with if-else