Fix bug in with_perf when block returns.

let me know what you think. thanks!