got code sort of working, still lots of work to do: