fixes condition for random time generation