exception handling to match spec