refactor floor_pivots function