generic record function