improved get_env method
fixed some stuff