Refactored after talking to @jassmith