Fixed is set check and moved env export up