Try to use this code: http://pastebin.com/YiaUWN5h