Undefined variable '$k'