performance improvment and ordering fix