Undefined variable/method fix