correctly set matrix