Fixed code to throw the exeption