Resolve "object is not a function" bug