function and control handling