added some debug messages & logging