handle environment, fix issues