 					console.log('Joined! Exiting.')
 					retryCallback()
 				.catch (err) ->
-					startServer(wifi)
-
+					connectOrStartServer(wifi, retryCallback)
 			else
 				console.log('Already connected')
 				retryCallback()

					throw err if err?
					console.log('Server listening')

console.log('Starting node connman app')
manageConnection = (retryCallback) ->
	connman.initAsync()

				console.log('Server closed and captive portal disabled')
				wifi.joinAsync(req.body.ssid, req.body.passphrase)
			.then ->
				saveToFile(req.body.ssid, req.body.passphrase)
			.then ->
				console.log('Joined! Exiting.')
				retryCallback()
			.catch (err) ->
