first try at refactoring
making into a gem