Fix for issue #41

Added a && short-circuit check so no null/undefined reference error accrues.
Merge pull request #43 from MattiasFestin/patch-1

Fix for issue #41