changed from machines_id to machine id and from devices_id to device_id