added exception handling for js