added on_exit functions to common.sh