updated model.py for error handling