Replaced switch with if else.