I'm trying to understand you're code, but it's complicated and it lacks structure. But what I think you're trying to do:

- User fills in 'backnumber' from top of list.
- System checks at what...