migrated machine.js from routes to models