move generic util functions to bottom

no real important app logic in there; about to refactor
converted result paging to iterator

python is pretty damn cool