smoothing out adjmat code