Move curve definition into function, this is the only place it is
called. I had problems with php calling global on an object.