this is two loops, one would be faster