fix NullPointerException
improve logging