More debugging - it now calculates gap percentage, but doesn't act on it