move code to class