Attempt to fix wierd sorting bug