added removeSmallest function