add diagnostic logging