It would be really useful to have a comment here explaining why this is the right logic.