I don't understand what this logic is. My implementation below attempts to do what I believe is correct behaviour rather than follow this.