add error handling on model