Moved dR calculation into a function