Solving empty comment bug and refactor of the list sorting function