avoid nullpointer exception, add logging