fix limit conditions bugs