fix dwell group algorithm