We have no way of knowing what this code is doing without the code that sets it up. Please do not post your whole program, just an SSCCE that demonstrates the problem. Don't forget the highlight tags.