implemented js exception handling