removed unnecessary variables and added comments