New query function

building view templates to hold output