enhanced exception handling method