It works according to the conditions but fail the validation. Don't know why, can anyone help?