Refactor: Use HashMap to record obatacles