Distance calculator is not operating properly