Fixing distance check in location template.