first level breadth search
refactoring