copied from jactor2