fixed bug in gates.py