Moved condition to formatting function to reduce redundancy.