Added a validity check