Fixes bug with index out of bounds error during the drawing of the function. Also adds function to window title