add end detection individually (next_step must be refactor)