since grid is always square, we can condense the @rows and @cols variables into one variable