fixed problem with 'this' inside loop