Added debug logging