Replaced long if-else clause with modulu operator