added generalize function