building simillarity matrices