Refactor task update