debugged and with Stat output