Fix duplicate checking