updating with sort routine