refac. and more detailed output