Added ability to loop. Also added some comments.