improve performance in similarity api