If you get a chance to look at one, have a look at the HZ model coding.