cleaning up environment logic