Good Gargoyle... top solution works as expected.

Your bottom posted code though does not return a value for me, please review your code so that it provides the expected results.