Modified code to match the instructions