changed correct input algorithm