Refactor task functions.