refactoring and new version for gem