removed dead code ($success), changed the connection state detection.
Merge pull request #159 from bibabu512/master

removed dead code ($success), changed the connection state detection.