check_unique_keys -> _check_unique_keys and improve efficiency