Undefined variable fix