Improved matrix() added converting from matrix to vector