converted q-function work to ipython