Fixed double creation of function during init