Modified the logic of all gates to prevent crashing if a value isn't set