DRYed some stuff out