last and final version of matrix. Refactored vertical and horizontal flip to work for when a row / column is inputted as 1