finalised creatingmatrixes