handle NPE gracefully