The code above would work for your specific example. There are probably more here in the forums.
This thread has some discussion using a table: