improved error handling and updated readme
code cleanup