fixed formatting function