Error handling added
closes #7