Move env check to lib/fun.