Revert "Fixed gate logic."

This reverts commit 7980d5f881e6f9b8e400c62691a1a17cd3ad781b.
Fix the fix.