some error handling modifications