added code that makes action depneding on operatin mode.