Refactor code into a partial