GUI object not found issue

Hello,

I'm trying to understand why this code isn't working.

import maya.cmds as cmds
 
winName = "myWindow"
dockName = "windowDock"
 
def gui(*args):
 
    global valueFLD
 
    if(cmds.window(winName, exists=True)):
        cmds.deleteUI(winName)
        print("Deleted existing window")
 
    if(cmds.dockControl(dockName, exists=True)):
        cmds.deleteUI(dockName)
        print("Deleted existing dock")
 
    cmds.window(winName, w=300, h=300)
    cmds.columnLayout()
    cmds.button(w=150, h=30,command=workPlease)
    valueFLD = cmds.intSliderGrp(v=2, min=1,max=1000,s=1)
    #cmds.showWindow(winName)
    cmds.dockControl(dockName, area="right",content=winName)
 
def workPlease(*args):
 
    currentValue = cmds.intSliderGrp(valueFLD, q=True, v=True)
    print currentValue

I use:

import windowTesting

reload (windowTesting)

windowTesting.gui()

to run the code.

The gui shows up as it should but when I click the button I get the error:

'myWindow|columnLayout17|intSliderGrp10' not found. # 

 If I uncomment the showWindow line and comment out the dockControl line it works fine, except of course it isn't docked, and I want it to be docked.  It also works if I just change the intSliderGrp to an intField.