homework 3... might have some errors