extracted a logic to detect the record existence as a helper method.