# Problems in using  Loop for executing Gatling Scenarios

**URL:** <https://community.gatling.io/t/problems-in-using-loop-for-executing-gatling-scenarios/3875>\
**Category:** Gatling (Open-Source)\
**Created:** [August 8, 2017, 3:16pm UTC](https://community.gatling.io/t/problems-in-using-loop-for-executing-gatling-scenarios/3875 "2017-08-08T15:16:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NITIN\_SHARMA](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@NITIN\_SHARMA](https://community.gatling.io/u/NITIN_SHARMA)\
**Post date:** [August 8, 2017, 3:16pm UTC](https://community.gatling.io/t/problems-in-using-loop-for-executing-gatling-scenarios/3875/1 "2017-08-08T15:16:49Z")

</div>

I want to execute some test steps in the loop based on the JsonObject. I wrote the following code but i guess we cannot execute chain builders withing session block.  
Can someone explain how can i execute the steps in loop based on the elements in the List of JsonObject.? I saw the documentation but still not clear. If someone has any sample code please let me know

.exec(  
session =\> {

val temp= session.get(“pa”).asOption[String]

tempmatch {  
case Some(map: String) =\> {  
val jsonAst = map.parseJson  
jsonObject= jsonAst.convertTo[SavingsJsonObject]  
for(pa\<-JsonObject.pa) {  
for(tempAcc\<- pa.tempAccount) {  
//steps to be called per Object information  
} }

}  
case None =\> println("\n “)  
case other =\> println(”\n " + other)  
}  
session

}  
)
