cut 25 lines of code and eliminated need for temp files