cleanup + add doctest