fixed the printGrid method