first working version of v2 script