rewrote delta time generation function