fixed code for linear searching