added environment handling