refine matrix.js