Code from brian marick's top down howto video