Changed to use Model.register
Fixed a condition