private static void improved_range_search(finger_print fp, double dis,
			Data data) {
		//System.out.println(fp.id);
		ArrayList<Integer> lst1 = new ArrayList<Integer>();
		HashMap<Integer, Integer> potent = new HashMap<Integer, Integer>();
		ArrayList<Integer> lst2 = new ArrayList<Integer>();

		// to be commented
//		for (int i : data.data_set.keySet()) {
//			if (fp.getDistance(data.data_set.get(i)) < dis) {
//				lst2.add(i);
//				//System.out.print(" " + fp.getDistance(data.data_set.get(i)));
//			}
//		}
//		System.out.println(lst2);
//		int s=lst2.size();
//		lst2.clear();
		
		int q_feat = fp.feature_size;

		/** binary **/

//		int feat_count = 0;
		double min_fts = 0;

		/***/

		/** non binary **/

		double num = 0;
		double denom = fp.feat_sum;

		/*****/
		boolean add = true;
		int f = 0;
		
		int gen=0;
		
		Collections.sort(fp.feat_present, finger_print.comp); // uncomment fsort

		//System.out.println();
		for (Integer fid : fp.feat_present) {
			add = true;
			if (finger_print.mn_ft_allpts_infeat.containsKey(fid)) {
				//System.out.println("No fo0 points in feature "+fid+" "+finger_print.invert_index.get(fid).keySet().size()* finger_print.mn_ft_allpts_infeat.get(fid));

				
				double temp = 0, max_sim = 0;

				/** binary **/
//				temp = Math.min(min_fts, finger_print.mn_ft_allpts_infeat.get(fid));
//				max_sim = (feat_count + 1.0) / (q_feat - (1 + feat_count) + temp);
				/****/

				/** non binary **/
				double q_sum = 0;
				double f_sum = 0;
				double temp_num = 0;
				double temp_denom = 0;

								
//				if (finger_print.non_bin) {
					double q_f = fp.feature_map.get(fid);
					temp_num = num
							+ Math.min(q_f, finger_print.max_ft_val.get(fid));

					temp = Math.min(min_fts, finger_print.min_sum_ft_val.get(fid));
					double a = fp.feature_map.get(fid);
					double b = finger_print.min_ft_val.get(fid);
					q_sum += a;
					f_sum += b;
					temp_denom = denom + temp - q_sum - f_sum + Math.max(a, b);
					max_sim = 1.0 * temp_num / temp_denom;
//				}
				/****/
				//System.out.println(dis);
				if (max_sim < 1 - dis) {
					
					//System.out.println("Rejected "+fid + " "+finger_print.invert_index.get(fid).containsKey(553)+" feature no "+gen+" "+fp.getDistance(data.data_set.get(553)));
					
					//f++;
					min_fts = temp;

					/*** non-bin ***/
					num = temp_num;
					denom = temp_denom;
					/****/
					
					// System.out.println(( feat_neglect.size()+1.0) / (q_feat
					// -1 - feat_neglect.size() + Math.max(max,
					// finger_print.mn_ft_allpts_infeat.get(fid))));
					
					add = false;
					//System.out.println("Feature no : "+ fid+ );
//					feat_count++;
				}

				if (add) {

					if (finger_print.invert_index.containsKey(fid)) {
						for (Integer id : finger_print.invert_index.get(fid)
								.keySet()) {
							if (!potent.containsKey(id)) {
								potent.put(id, 1);
								lst1.add(id);
							}
						}
					}
				}
			}
		}
		//System.out.println("percent pruned "+1.0*f/fp.feat_present.size());
		//System.out.println("Features pruned "+feat_count);
		//System.out.println("rehected no of feats " + f);
		for (int i = 0; i < lst1.size(); i++) {
			int j = lst1.get(i);
			if (fp.getDistance(data.data_set.get(j)) < dis) {
				lst2.add(j);
				//System.out.print(" "+ fp.getDistance(data.data_set.get(lst1.get(i))));
				// System.out.println("Point "+j);
			}
		}
		
//		if(lst2.size()!=s){
//			System.out.println("NNNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOO");
//		}
		
		//System.out.println(lst2);
		//System.out.println("Candidate point list size "+lst1.size());
		//System.out.println();
	}