-moved Matrix implementation to the bottom of the file