Api build/sorting. Need testing