Error handling added.