improve error handling and model attributes