added null check, fixes #31