Remove duplicate logging and error handling code