complete, but need debugging