created variables and if statements

Line.17 - if statement to break loop
line.19 - if , else if and if statement for function