Add Matrix indexer

and Fixed some logics