Look at the code in my first comment. It should contain all the basic structure you need.