kind of got the basic system working, though it has a lot of robustness issues