Move functions outside env block