Refactored duplication out of ruby methods