[BUG #7704] forked out two larger subroutines from handleFunction()

- for better maintenance
- and further refactoring