Created gate merger logic. Untested.