refact core.sh