distance and average fns
added alternate master/client