size of matrix in function, bugs fixes