changing to Matrix functions