ENH:modify interface and add error handling