cleaned code
Implemented BFS