added more error handler