migrate code to a class