Make the loadmatrix become a function