fixed small bug and added ordering