prelim code - unvectorized form.