Changed code structure to declare all variables at the top of the page. Added an alert to show results.