added loops, for loop still needs trvar