ugly prototype with nested lists but it does work