Renamed function to avoide clobbering and added debug messages