Added bounds check for num_days