You haven't tested for size == 0