Used OP's original code, fixed placing of it, which caused it to not compile.