just made some semantic changes and added more comments