detect thinning interval and refactor