second draft code cleanup