Fixed bug when re-scheduling task