fix bugs and env