fixed bug when time offset is negative