refactor isvalidate function

add id validation in