Fixed the gatesimulation