adjust removeBefore logic in big array