Fix matrix order bug