Added validation and docstrings