Fixed exception code to return correct values