added comments and changed variable names so it reads more like English