filtering and sorting added for deadlines. !TO BE TESTED!