fixing matrix updater so that it runs faster