added improved error handling and modified the README