refactored script into gem