added undefinded exception handling