Fixed the invalid parameter - environment exception

The commit says it all.