updated virtual grid code