improve require func