Added polarity switching on the loop

Lab4 task J