another solution with validate method