made file reading async and cleaned up