final version used in ipython notebook
final version used in ipython notebook