changed the way end runs are detected