add some error checking and use files for logic