Added validity check
Added validity check