adding status codes, fixing sorting