rolled pieces of foo2 into other functions