fix bug in callback functions to ensure presence of env variable