Refactor record.js