Moved controller code from view to controller
We added an error message for validating uniqueness