Refactored registration code to use new model functions