fixed memory leak and doubled const declare