Replaced if statements with switch/case to make code neater