added incrementing function  added for m3d