refactored registration js