used contains method instead of charAt