Refactored formatted id handling