Move func def to toplevel; thanks @josenavas