re-wrote portions of register script