adding matrix features and reorganizing