Fixed the invalid parameter - environment exception

The commit(s) says it all.