fixing sort function; updating schema