if bindex(end) ~=k
... And There Was Light.
Disclaimer: code doesn't really produce light. It won't cause despair, either. It actually doesn't do anything of any interest to anyone but me (and possibly my boss). But I wrote it all by myself!