Optimized the cpp code by using more effiecent stl code