I think the most important thing is to have something that works. (Which you apparently do.)

Now, thinking about efficiency without basically changing your approach, I have a couple of...