Refactor into Gem - Work still in progress