api change environment_init()
code optimization
code cleanup
code cleanup
no need for length check
remove local variable and smart switsch statement