cleaned it up. added some error handling.