new approach: subfunction as class