Add doctests
Simplify