Fix: use a safer check to find gws.