changes based on in-class discussion. needs testing.