Adding error logging snippet