switched order of if/else statements