Rewrote some code to conform with DRY standards