enhanced exception handling