refine herbenvironment to solve out of boundary problem