Why my form is not working consistently?