Have a look on how i do this in glvg.