added spy function