- error handling.
- added some comments.