changed some things in matrix and added swap

Not sure if it works still also I don't know if it was implemented
recursively.