refactor convert_to_data_type into a method