extended value search to range search corrected version