Fixed issue with calling to function on non-object