Added if statement
added a for loop
delete a line of conde