improving time restriction logic