Move function to common.js