Added some model validation code