distance and bearing calculation is now working
rewritten code in some functions