initial code for results; needs review for efficiency