public ISemiSpaceTuple findOrWaitLeaseForTemplate(Map<String, Object> templateSet, long timeout, boolean isToTakeTheLease) {
        final long until = admin.calculateTime() + timeout;
        long systime = admin.calculateTime();
        String tag = (String)templateSet.get("tag");
//        log.logDebug("findOrWaitLeaseForTemplate "+templateSet+" "+timeout);
        ISemiSpaceTuple found = null;
        long subtract = 0;
        do {
            final long duration = timeout - subtract;
            if (isToTakeTheLease) {
                statistics.increaseBlockingTake();
            } else {
                statistics.increaseBlockingRead();
            }

            found = findLeaseForTemplate(templateSet, isToTakeTheLease);

            if ( found == null && duration > 0) {
                elements.waitHolder(tag, duration);
            }
            if (isToTakeTheLease) {
                statistics.decreaseBlockingTake();
            } else {
                statistics.decreaseBlockingRead();
            }

            final long now = getAdmin().calculateTime();
			subtract += now - systime;
			systime = now;
        } while (found == null && systime < until );
        return found;
    }