Wrote proper exception handler