new design with class instead of function