Fixing callback undefined problem