Implemented similarityIndex function