improve violation and reward functioin