fix misplaced endif