computing similarity
passing as reference and huge improvement in speed