Ensuring that duplicates are not inserted