Got rid of duplicate code for sorting of news feed