Fixed error handler bug