I think this would be clearer if you didn't have the nested function here.  Just put the creation code directly in the constructor.