correcting the erroneous code