Refactoring similarity method.