updated primary query