[performance] break "if-else-if-else" chain to separate parts so they could be moved around