added max distance