Apex: fixes issue with detecting proper gate scenario