fix bug with env == NULL