Refactor to wrap each method in a function