implement proper exception handling.