stupid me again, working inside loop