Fixed time-wrapping bug