Moved record logic into record.js