while (keys.hasNext()) {
String sessionId = (String) keys.next();
Session session = Session.getExistingInstance(sessionId);
if (session == null) continue;
long lastActiveTime = session.lastActiveTime();
Status status = session.getStatus();
if (status != Status.SUCCESS && status != Status.FAILURE
&& status != Status.INITIAL
&& now - lastActiveTime > inactivityLimit) {
String message = "*** Forcefully terminating script. \nNo response from browser within expected time ("
+ inactivityLimit / 1000 + " seconds).";