Fixed a bug where a function was calling an invalid function