updated end_run checking #370