added validity check