added code error handler