Finished second function

added the compare function
edit comments