Now it saves similarities ot the database, but still it runs too slow.