edited the editTask method to handle more errors