Rewrite function to Class