State duration calculations added