improved error handler; refactoring
debugging