Refined and tested. Has worked for 3 expressions, covering a range of tests.