move functions as values and nested functions to advanced