implemented matrix hierarhy