If you want help, you'll have to provide an SSCCE that demonstrates the problem. We can't do much by looking at incomplete (or overly lengthy) code.