updated for clarity, broke 3 out into 3 files