Ignore 'function in loop' issue - not a big problem as in example code