How to re-order conditions