fix reversed matrix