Make sure env is defined before used