It sounds like you are doing something simple in a very roundabout way. Explain instead the intended outcome and many people will be happy to help.
Reply on news.ycombinator.com