simplify beforeRun logic