removing unecessary imports
fixing some problems uncovered by tests
catch the proper error
removing  (should fix the problem instead)