mostly working, need to preserve output state