code refactor to bind functions to tasks