add filter, sorting and null pointer exception fix