Fixing a null pointer error

I happened while I was trying to connect.
Merge pull request #221 from arthurbenemann/BugFix_NullPointer

Fixing a null pointer error