refactor printing of the dict and clean up imports