functionaly working, except no spectrum, prototype code -- commit before tidy up