Streamline ipython detection code