removed code to convert to data.frame, it does this anyway if data is a matrix via an if statment that checks the number of rows and columns