simplify and fix a bug with connection errors when using promises
Merge pull request #4 from phated/master

simplify and fix a bug with connection errors when using promises