fixed typos, fixed const, removed duplicated functions