Refactor to remove repeat code and clean up of lengthy methods