added some debug messages and fixed copy paste error