added standard error handling