Converted current MapGrid code into a class