Fix undefined callback issue