Refactored remote.js