Adding debug logging code