adding validate funcionality