bug fix and parameter adjustment
add state management