add error level logging, protect against null pointer crashes