fix logic error with debug mode