refactoring api data into records