Added matrixtrim function