end of run detection