redoing the internals of the HeightMap function