This is kind of confusing to read the way you have function(function(, suggest doing the inner function call and then passing the result.