newSwitch in modular approach

To write as clean code I thought I’d put custom widgets controls in a file other than the main.lua. But what is the correct way for retrieve switch state from the external file?
 

-- controls.lua local widget = require( "widget" ) Switch {} -- Create the widget function Switch:new = widget.newSwitch { left = 250, top = 200, style = "onOff", id = "onOffSwitch", onPress = onSwitchPress } -- Handle press events for the switch function onSwitchPress( event ) local switch = event.target if (switch.isOn) then state=true else state=false end return state end Switch.state = onSwitchPress end return Switch;

 
In main file:
 

-- main.lua require("controls") local Accell = Switch:new() local state = Accell.state  --?????? is correct way?

 
in main.lua “state” variable is nil.
 
Any suggestions?
Thanks in advance.
-jospic