Refactor code into usable utility method for later