working through addition of new query variables -- buggy version