made better by @will

see updated SO http://stackoverflow.com/a/15623322/1037948