fixed bug in environment variable handling