make sure object is type function before calling, cleanup