made error handling more robust and reported errors in the correct way.