lots of stuff, need debugging