> I was planning on implementing something like this this week!

Common wavelengths are amazing common around here :-)
Perhaps then you'd be interested in what I have suggested about buiding
a general purpose class for these use cases?