This is only partial code- can you provide an SSCCE that we can copy and paste to run and see exactly what's going on?