finished basic outline, not tested yet