Changed generating logic for named functions

Generate it as a sequence of statements when it's possible