compute pt once
optimize sorting, add warning