removed extraneous variables and added comments