My original code was a bit finicky, but there are discussions of this in other posts and other forums. I took a slight variation of what others did with what I was doing and it seems to work well. You can compare my source code to this and do what works best for your situation... hope this helps.