added some diagnostic logging