use closure to detect environment
resolve conflicts