removed unnecessary variable and simplified the math