moved whichFunction to toplevel