added minor error handling