renamed and deleted a few variables, added comments