use map and queue