routine was previously building invalid matrix