How about restricting the user to enter only upto 1? You don't have to write long code like this then.