Fixed some bugs with the validation