fixed run routine with delay and other optimizations