refactored the rest of the .js code out of the results stage and mildly changed the style.