made the functions, tested with a single matrix