refactored to use ruby dialect