switched order of if-else