Add docstring, more checking