Refine validity checking