move some procedure to definitions