bug fix in gates.py