Bug fix of remove duplicate block function

Hi Yuyi,

this patch fixes the problem with the remove duplicate block function not working properly.

Could you review and merge, please?

Thanks,
Manuel