Refactor getting task