improved

rewritten files loop