finished! just needs test cases