added copyright and corrected isvalid function docstring