This isn't actually required to fix the behaviour but it does feel like a better place to put this logic.