Separate ID creation from the main logic.