sample code provided by Techn Pwn on vexforums