matrix code finished, untested