add exception handling in callback function