bug for ending if statement