change if-else structure for better performance