fixed bug with wrong variable name
cleaned up code by removing unnecessary variable