moved code to common.js