bug fix and update duty code