convert switch to if-else, trying better perf