Wims' code does work if you want to just use that.