Fix sorting function
Implement update action
Improve sorting