Added nested loop and string function