kristarella has a nice article on writing your own custom loops.