 					#console.log(s_wk_client._zmq.state,jobs.length,options.max,freemem);
 					switch s_wk_client._zmq.state
 						when zmq.STATE_CLOSED
-							if os.freemem() - options.memJob * 1048576 * jobs.length > options.minMem * 1048576
+							if heathOk()
 								console.log 'connecting...'
 								s_wk_client = zmq.socket('pull')
 								s_wk_client.on 'message', on_message
 								s_wk_client.connect options.uri
 						when zmq.STATE_READY
-							if os.freemem() - options.memJob * 1048576 * jobs.length < options.minMem * 1048576
+							unless heathOk()
 								console.log 'disconnecting...'
 								s_wk_client.close()
 								s_wk_client = '_zmq': 'state': zmq.STATE_CLOSED

			s_wk_client.on 'message', on_message
			s_wk_client.connect options.uri
			setInterval updateState, 1000
			r.listening = true
			return
		'monitorJob': (jobId) ->

								item._lastchange = ~~((new Date).getTime() / 1000)
					console.log "Reenqued", reenques,"jobs" if reenques > 0
					workingSync = false
			updatingStatus = false
			updateStatus = ->
				if r.ready and !updatingStatus
					updatingStatus = true
					jumpon++
					status_c = {}
					tokill = []
