records and figure plot refactoring