--implemented create matrices function