added debug logging