common.js: organize code