First version of working spectrum code