Moved require inside function