Updated method get_data with better invalid argument checks