properly calling the gate function now