reorganized to use Matrix and Array Base