errorHandler function added