improve performance when several matrices multiply