Added some if statements and junctions.