Fixed compiler error and removed unnecessary variable