Fix duplicate record problem