private Coord getGridLoc(int x, int y) {
		
		int cellWidth = getWidth()/(board.getCols()+1);
		int cellHeight = getHeight()/(board.getRows()+1);
		int xMargin;
		int yMargin;
		
		if(cellWidth<cellHeight) {
			
			cellHeight = cellWidth;
			xMargin = cellWidth;
			yMargin = (getHeight() - ((board.getRows() - 1)*cellHeight)) / 2;
			
		} else {
			
			cellWidth = cellHeight;
			xMargin = (getWidth()-((board.getCols() - 1)*cellWidth)) / 2;
			yMargin = cellHeight;
			
		}
		int xPos = (x-xMargin+cellWidth/2)/cellWidth;
		int yPos = (y-yMargin+cellHeight/2)/cellHeight;
		
// if outside the board
		if (xPos < 0 || yPos < 0 || xPos >= board.getCols() || yPos >= board.getRows()) {
			return null;
		}
		
		return new Coord(xPos, yPos);
	
	}