+ added errorHandler
+ small code refactoring