fix null pointer exception (fixes #1)