Make code more modular in from.js