else was in wrong if-else statement