Create function to check if a cell on given row and col is valid, to avoid repetition of code.