reduced iterations in modes.get function