add code. First attempt; not yet tested