Added error handling and public documentation