add better handling of errors
add better handling of errors