creating the correct query call