made changes to run in ipython