improved on formatting function