implement the record function