finished up section 1 but code seems very inefficient