Fixing bug in form validation