Added logging for errors