Finished to adjust the code to the comments given