The right logic for this task

Please read How to share code or flow json and then EDIT your post and fix it so it can be imported.