Speeds up bucket retrieval to avoid quadratic runtime