Fixing matrix scale function