function parser and wrapper (closure doesn't work as expected)