Fixed bug in the toggle_task method