gating works... But need some improvement