Refactored create contact history function