Added some if statements to running same code multiple times