fixed enhanced for loops in Main and MongoJSONFactory