first version of Smart Height Grids algorithm :)