second attempt to fix NullPointerException