Improved readability of expandFormat function