Rename internal `envs` in order not to hide the method.
Fix variable naming issues and catch proper exceptions.