move function to toplevel within class