use sql for order actions. This should be faster