functions for gathering and processing results