Fixed matrix bug