Updated method get_data with checks for valid arguments.