convert function to class