fix global name 'top_word' not defined runtime error encoutered during manual testing; Wrap up the interactive console