Class adding function