exteded version for 2D (with functions inside / on edges)