null pointer fix and logs