did DRY and removed cruft