Matrix implemenation completed