Refactor the formating & managing errors on stdout