Improved last comma handling