fixed error conditions that would kill the script