- added comments and renamed some variables