added more extensive error handling