Strictly speaking the same functionality could just be placed under this if statement. I do agree that it would be cleaner to have such a callback function though.