@SuppressWarnings("unchecked")
	public void delete(T node, Database db, ConsistentHashTest cht){
		Long presentServer;
		
		for(int i = 0; i < noOfVirtualNodes; ++i){
			presentServer = hashFunction.getHash(node.toString()+i);
			
			Long previousLink = ((TreeMap<Long, T>) circle).lowerKey(presentServer);
			Long nextLink = ((TreeMap<Long, T>) circle).higherKey(presentServer);
			
			Long previousServer = previousLink!=null ? previousLink : circle.lastKey();
			Long nextServer = nextLink!=null ? nextLink : circle.firstKey();
			
			@SuppressWarnings("rawtypes")
			SortedMap<Long, Data> subMap = new TreeMap(),temp1,temp2;
			if(presentServer.equals(circle.firstKey())){
				temp1 = (db.getDataMap()).tailMap(previousServer);
				temp2 = (db.getDataMap()).headMap(presentServer);
				//System.out.println(subMap);
				//System.out.println(temp);

				subMap.putAll(temp1);
				subMap.putAll(temp2);
			}
			
			else {
				subMap = (db.getDataMap()).subMap(previousServer, presentServer); 
			}
			//System.out.println(subMap);
			
			//now change the entry for orders in database
			Set<Entry<Long, Data>> set = subMap.entrySet();
			Iterator<Entry<Long, Data>> it = set.iterator();
			//System.out.println(set);
			while(it.hasNext()){
				
				Entry<Long, Data> me = it.next();
				String nextServerName = (String)circle.get(nextServer);
				//System.out.println(nextServerName);
				db.add(me.getKey(), me.getValue().getOrderId(), nextServerName);
				String presentServerName = (String) circle.get(presentServer);
				//System.out.println((cht.getServerNameMap()).get(presentServerName));
				(cht.getServerDetails()).put(presentServerName, (cht.getServerDetails()).get(presentServerName)-1);
				(cht.getServerDetails()).put(nextServerName, (cht.getServerDetails()).get(nextServerName)+1);
			}
			
			circle.remove(presentServer); //delete the replica of the server from the map
			
			
		}
	}