Moved displaying results to a separate function.