fixed extend_environment