fix bug occurring when deleting a task and creating a new one