                             else
                                 if complete[i] == false
                                     complete[i] = true
-                        i++
 
-                    pgHoff.renderResults(resultsets, pgHoff)
+                    @renderResults(resultsets, pgHoff)
                     if !complete.some( (val) -> return val == false )
                         clearInterval(interval)
 
-                .catch (err) ->
+                .catch (err) =>
                     console.error 'catch', err
                     clearInterval(interval)
                     atom.notifications.addError(err)
         , atom.config.get('pg-hoff.pollInterval'))
 
     executeQueryWithConnect: ->
-        alias = atom.workspace.getActivePaneItem().alias
-        pgHoff = @
-        if (alias)
-            pgHoff.executeQuery()
+        if atom.workspace.getActivePaneItem().alias?
+            @executeQuery()
         else
-            promise = @connect()
-            if not promise?
-                return
-            else
-                promise
-                    .then ->
-                        pgHoff.executeQuery()
-                    .catch (err) ->
-                        console.error 'Connect error', err
-                        atom.notifications.addError('Connect error')
+            return @connect()?.then =>
+                    @executeQuery()
+                .catch (err) ->
+                    console.error 'Connect error', err
+                    atom.notifications.addError('Connect error')
+
     executeQuery: ->
         selectedText = atom.workspace.getActiveTextEditor().getSelectedText().trim()
         pgHoff = @

                        else
                            complete.push(true)
                if queryStillExecuting
                    pgHoff.keepGoing(result.url, complete, pgHoff)

                pgHoff.renderResults(result.resultsets, pgHoff)
            .catch (err) ->
                atom.workspace.getActivePaneItem().alias = null
                pgHoff.resultsViewPanel.hide()
                atom.notifications.addError(err)

            if atom.config.get('pg-hoff.executeAllWhenNothingSelected')
                selectedText = atom.workspace.getActiveTextEditor().getText().trim()
            else
                resultsViewPanel.hide()
                return

        return PgHoffQuery.Execute(selectedText)
            .then (result) =>
                complete = []
                queryStillExecuting = false
                for resultset in result.resultsets
