added formatting function + minor changes