fix bug in mesh generation