minor changes; generalization