cleanup of exception code

cleaner version of the same function with two params added.