move common code into common.js