Small refactoring using -when-let.