Fix undefined function bug