added validictory functionality and error handling; added tests