Reduce duplication

this is just to clean up some code smells reported by code climate