Fixed memory bug, adjusted example