inefficient and ugly predecessor search