moving script code to ui