added loopTable function and applied it twice. Working on more times