Use correct index for inner loop
Modify formatting within paste function
Fix indentation