factor stuff into common.sh