clean up if-else block