rewritten code for c_map and also other classes