basic outline, minus any thread management