remove global functions and create closure initializers