fix misplaced end