Completed function get_data