better file handling, removed extraneous imports