adding minor error handling improvement