Changed martix representation to a maximum of 8 columns and rows