Wrapping in function does not work