part way done, has some errors