using while loop to do sequetial search