refactoring record handling