added exception handling and model validation