fix period = 0 bug