Improve clarity of edge case formatting logic