update import functionality to calculate max id dynamically