added invalid input check for row and column