Make the logic more flexible to work across environments