implements switch instead of if/else