Some refactoring to DRY up the code. Needs more
Refactored to allow any number of rows and columns