Replace positioning function with popup helper