sample code for basic recording/replaying