optimization for removing excess else if