Improve the unique check