add exception handling to hooks