Update gates.cpp