added error handling for nodejs