Switched to using ifElse, because "switch" statement is not supported in earlier versions of Java