corrected the code as recommended