handle nested functions