added distance functions, added file parser