fix exception handling