extracts callback into a function expression
hoists variables