added loop feature