Fixed: use "if-else" replace "switch" for better performance