Improved code

- added error trap.
- modified function descriptions.