Move duplicated functions to common.js