fix boundaries bug