added further error handling