changed sorting method, a little faster, still too slow