Separated files, formatted,  and fixed loop