Refactor to named functions.