finished pointer based bfs algorithm, but not verifying correctly yet