fix bug with sort