move script code to common