Adjusted initial code and added output