cleaned up exception handling