Refactor into method and add instructions to README