Streamlining with find_bucket function