add output matrix
clean up
looking for the envelope