in reply to matrix multiplication

You are assigning the return value of close to to @mat1 and @mat2.

Really, before asking a question here, some basic debugging would be good. At least you could have tested whether multiply got the parameters you expected -- and then you could have realized that the bug is nowhere near you think it was.