changed spyOn function