Added validity chacking