Adding method toArray() in Record class