Added user sorting and a small bug fix