For loop search isn't running