updated error message and cleaned logging