refactored idPrefix generation code