Some refactoring for getCellByCoords()