try to refactor register script