When replacing the result, remove the previous result after the new one was inserted.
(cherry picked from commit 63c2b4242b2b4beac5227909981a7cf4efc60b7f)