Fix bug of checking duplication in array and core data