fix counter and make delay a var