Help with Procedure

Ok , Sorry for not clearly mentioning what I want to do. I hope this post clearly mentions what exactly I want to do

For that I am using this


If you can see the set of blocks encircled in red , they are repeating over and over again , at different instances (only 2 such instances are mentioned). Wherein The then conditions are varying according to the requirement. The main Aim is to check for an internet connection before calling a firebase component. (Rest blocks cleared to avoid unnecessary confusion)
What I want is not to repeat the blocks encircled with red , create a function ( or procedure) for those 3 blocks , Where my input in each case will be different i.e condition in then part.

I hope this clearly explains what I want to do. If not , I am sorry I would present it in a better way.

Thank You ,
Regards
Kunj