Fix: generate contact matrix