The coded version of number 1 was done horribly.

I like the template Scott (sgraham) posted.