added some error checking/handling.  Work in progress.