implemented rmsd calculation