fix query logic and add validation to episode_number